<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        function MyObject () {
            var privateVariable = 10;
            function privateFunction () {
                return privateVariable;
            }

            this.publicMethod = function () {
                privateVariable ++;
                return privateFunction();
            }
        }

        var a = new MyObject();
        console.log(a.publicMethod()); // 11
        console.log(a.publicMethod()); // 12
        console.log(a.publicMethod()); // 13
    </script>
</body>
</html>
